<?php

namespace KernelModule\LogsModule;

use \KernelModule\BasePresenter;
use Albireo\Mode;
use Albireo\MenuGenerator;

/**
 * Kernel Logs main presenter
 *
 * @author     Pavel
 * @package    Kernel
 */
class OverviewPresenter extends BasePresenter {

    /**
     * If we are in the critical mode, only PHP logs are available. So we are
     * redirected instantly.
     */
    public function actionDefault() {
        if (Mode::isCritical()) {
            $this->redirect('Php:Process:');
        }
    }

    public function renderDefault() {
        if(!isset($this->template->title))$this->template->title = _("Kernel Logs");
        $this->showMenu();
        $this->showLogsMenu();
    }

    protected function showLogsMenu() {
        $logsImPrefix = "images/kernel/logs/";

        $items = array(
            "Kernel:Logs:Php:Process" => array("action" => "default", "icon" => $logsImPrefix."php.jpg", "title" => _("PHP Error Logs")),
            "Kernel:Logs:Acl:Display" => array("action" => "default", "icon" => $logsImPrefix."acl.jpg", "title" => _("Security Logs")),
        );
        $menuGenerator = new MenuGenerator();
        $menu = $menuGenerator->universalMenu($this->getUser(), $items);

        $this->template->logMenu = $menu;

    }

}